package com.mongo.service.impl;

import com.mongo.service.BaseService;
import com.mongo.service.MongoMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.lang.reflect.ParameterizedType;

/**
 * @author xiazhun
 * @create 2022/9/16
 */
@SuppressWarnings("all")
public class MongoServiceImpl <M extends MongoMapper<T>, T> extends BaseService<T>{

    @Autowired
    protected M baseMapper;

    @Override
    public void afterPropertiesSet() throws Exception {
        ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
        // 获取第一个类型参数的真实类型
        super.clazz = (Class<T>) pt.getActualTypeArguments()[1];
        super.afterPropertiesSet();
    }
}
